package encapsulation;

/**
 * @classname:calculator
 * @description:
 * @author: Mr.Z
 * @date: 2020/11/27 22:49
 * @version: 0.1
 * @since:1.8
 */
public class Calculator {
    private int num1;
    private int num2;
    private String operate;

    public Calculator() {
    }

    public int getNum1() {
        return num1;
    }

    public void setNum1(int num1) {
        this.num1 = num1;
    }

    public int getNum2() {
        return num2;
    }

    public void setNum2(int num2) {
        this.num2 = num2;
    }

    public String getOperate() {
        return operate;
    }

    public void setOperate(String operate) {
        this.operate = operate;
    }


    public int operation() {
        switch (this.getOperate()) {
            case "+":
                return this.getNum1() + this.getNum2();
            case "-":
                return this.getNum1() - this.getNum2();
            case "*":
                return this.getNum1() * this.getNum2();
            case "/":
                return this.getNum1() / this.getNum2();
        }
        return 0;
    }
}
